package controler.states;
import controler.A_State;
import controler.userCommands.AddToSelection;
import controler.userCommands.ChangeElementProperty;
import controler.userCommands.EditPhysicShape;
import controler.userCommands.SwitchState;
import graphic.RenderObject;
import model.LevelEditorModelEvent;
import phx.Vector;
import view.events.LevelEditorViewKeyboardEvent;
import view.events.LevelEditorViewMouseEvent;
import view.events.LevelEditorViewOtherEvent;
import model.ModelUpdateType;


/**
 * @author Damien Mabin
 */

class PhysicShapeEdition extends A_State
{

	public function new()
	{
		super();
		this.addEventListener(LevelEditorViewMouseEvent.EVENT, OnLevelEditorMouseEvent);
		this.addEventListener(LevelEditorViewOtherEvent.EVENT, OnLevelEditorViewOtherEvent);
		this.addEventListener(LevelEditorViewKeyboardEvent.EVENT, OnLevelEditorViewKeyboardEvent);
	}
	
	private function OnLevelEditorMouseEvent(_Evt:LevelEditorViewMouseEvent):Void
	{
		switch(_Evt.m_Type)
		{
			case MOUSE_DOWN :
			{
				switch(_Evt.m_TargetType)
				{
					case PHYSIC_POINT :
					{
						A_State.s_Controller.DoUserCommand(new AddToSelection(A_State.s_Controller.PHX_PT_SIMPLE_SELECTION, Vector, _Evt.m_Target));
					}
					default :
					{
					}
				}
			}
			default :
			{
				
			}
		}
	}
	
	private function OnLevelEditorViewOtherEvent(_Evt:LevelEditorViewOtherEvent):Void
	{
		switch(_Evt.m_Type)
		{
			case EDIT_RENDER_OBJECT_PHYSIC_BODY(ro) :
			{
				A_State.s_Controller.DoUserCommand(new EditPhysicShape(A_State.s_Controller.INITIAL, ro, false));
			}
			case CHANGE_RENDER_OBJECT_PROPERTY(ro, type, value) :
			{	
				A_State.s_Controller.DoUserCommand(new ChangeElementProperty(null, RenderObject, ro, type, value));
			}
			default :
			{
				
			}
		}
	}
	
	private function OnLevelEditorViewKeyboardEvent(_Evt:LevelEditorViewKeyboardEvent):Void
	{
		
	}
	
}